package com.example.myapplication.ui.fragment.project

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.myapplication.request.CollectRequest
import com.example.myapplication.request.ProjectRequest
import kotlinx.coroutines.launch

/**
 *项目文章的viewModel
 *
 * @author : Kun
 * @date : 2021/6/16
 * @time : 13:16
 */
class ProjectArticleViewModel : ViewModel() {

    /**
     * 文章相关的请求
     */
    val projectRequest = ProjectRequest()

    /**
     * 收藏相关的请求
     */
    val collectRequest = CollectRequest()

    /**
     * 请求项目列表文章
     */
    fun requestArticleList(index: Int, cid: Int) {
        viewModelScope.launch {
            projectRequest.requestArticleList(index, cid)
        }
    }

    /**
     * 取消文章收藏
     */
    fun requestDelCollectArticle(id: Int) {
        viewModelScope.launch {
            collectRequest.requestDelCollectArticle(id)
        }
    }

    /**
     * 新增文章收藏
     */
    fun requestAddCollectArticle(id: Int) {
        viewModelScope.launch {
            collectRequest.requestAddCollectArticle(id)
        }
    }

}